#ifndef _COMM_H
#define _COMM_H

/* Includes ------------------------------------------------------------------*/
#include "Tea.h"
#include "Time.h"
//#include "Si446x.h"
#include "Address.h"
#include "AutoTest.h"
#include "DataPoint.h"
#include "key.h"
#include "SysVariableInit.h"

extern volatile KEYHANDLE KeyHandle;
/* Private typedef -----------------------------------------------------------*/
typedef struct
{
     uint8_t TxFlag;
     uint8_t TxTimes;
     uint8_t DelayedTime;
}COMMREPEAT; 

typedef struct
{
     uint8_t Flag;
     uint16_t Delay;
     //uint8_t DelayedTime;
}HALLTIMEOUT; 

/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Referencing variables -----------------------------------------------------*/
extern volatile uint16_t ConfigResponseDelay;

extern volatile uint8_t RadioChannelSelect;
extern volatile uint8_t RadioConfig_LastCmd;
extern volatile uint16_t RadioConfig_SameCmdDelay;
extern volatile TIME1MS Time1Ms;
extern volatile HALLTIMEOUT HallTimeOut;
#ifdef USART
   extern volatile uint8_t SerialTxBuf[10u];
   extern volatile uint8_t Serial_CurTxCount;
#endif
/* Private function ----------------------------------------------------------*/
/* Referencing functions -----------------------------------------------------*/
extern void RadioProcess(RADIOFRAME *RxPtr);

extern void RadioRxCommProcess(RADIOFRAME *RxPtr);
extern void RadioTxCommProcess(RADIOFRAME *TxPtr);

extern void AcknowledgeProcess(ACKFRAME *RxPtr);
extern void AcknowledgeTxProcess(ACKFRAME *TxPtr,uint8_t Type);

extern void MessageProcess(MSGFRAME *RxPtr,RADIOFRAME *TxPtr);


extern void MemoryReadProcess(MEMORYFRAME *RxPtr);
extern void MemoryWriteProcess(MEMORYFRAME *RxPtr);
extern void MemoryResponseStateProcess(MEMORYFRAME *TxPtr);
extern void DeviceTestTxProcess(RADIOFRAME *TxPtr,uint16_t val);

extern uint8_t BootUpdateTransmitProcess(UPDATETRANSMITFRAME *RxPtr);

#endif
